var builder = DistributedApplication.CreateBuilder(args);

var apiService = builder.AddProject<Projects.MasterNeverDown_AspireStarter_ApiService>("apiservice");

builder.AddProject<Projects.MasterNeverDown_AspireStarter_Web>("webfrontend")
    .WithExternalHttpEndpoints()
    .WithReference(apiService)
    .WaitFor(apiService);

var redis = builder.AddRedis("cache");

var username = builder.AddParameter("username", secret: false);
var password = builder.AddParameter("password", secret: false);
var rabbitmq = builder.AddRabbitMQ("messaging",username,password)
    .WithManagementPlugin();;

var postgres = builder.AddPostgres("postgres")
    .WithDataBindMount(
    source: @"C:\PostgreSQL\Data",
    isReadOnly: false)
    .WithPgWeb(pgWeb => pgWeb.WithHostPort(5050));
var postgresdb = postgres.AddDatabase("postgresdb");
// var rabbitmq = builder.addr("messaging");




// builder.AddProject<Projects.MasterNeverDown_EverythingIOT_Modbus>("masterneverdown-modebus");
var management = builder
    .AddProject<Projects.MasterNeverDown_EverythingIOT_DeviceManagement>("device-management")
    .WaitFor(rabbitmq)
    .WaitFor(redis)
    .WaitFor(postgresdb)
    .WithReference(redis)
    .WithReference(rabbitmq)
    .WithReference(postgresdb);

builder.AddProject<Projects.MasterNeverDown_EverythingIOT_Modbus>("modbus")
    .WaitFor(rabbitmq)
    .WaitFor(management)
    .WaitFor(postgresdb)
    .WithReference(rabbitmq)
    .WithReference(management)
    .WithReference(postgresdb);

builder.Build().Run();
